#ifndef _COMMON_API_H_
#define _COMMON_API_H_

#include "compiler.h"

//const define
#define SYS_TICK_1ms          (WORK_CLK/8000)
#define SYS_TICK_1us          (WORK_CLK/8000000)

#define SYS_TICK_1ms_SLOW          1000
#define SYS_TICK_1us_SLOW          1

#define SysTick_CTRL          (*((uint32_t *)0xE000E010))
#define SysTick_LOAD          (*((uint32_t *)0xE000E014))

#define CRC32_CHECK_CODE       0xa55aa55a

//extern unsigned int crc_table[256];  

void init_crc_table(void);  
unsigned int crc32(unsigned int crc, unsigned char * buffer, unsigned int size);  

//uint32_t check_sum(uint8_t* buff, uint16_t len);

/*****************************************************************************
** Function name:
**      sys_tick_delay_ms

** Descriptions:
**      using the systick to do delay some ms
**
** parameters:
**      dly_ms------the millisecond to delay
**
** Returned value:
**      none
** note:
**      MAX delay time is 1597ms
**
*****************************************************************************/
void sys_tick_delay_ms(uint32_t dly_ms);


/*****************************************************************************
** Function name:
**      sys_tick_delay_us

** Descriptions:
**      using the systick to do delay some us
**
** parameters:
**      dly_us------the microsecond to delay
**
** Returned value:
**      none
** note:
**      MAX delay time is 1597830us
**
*****************************************************************************/
void sys_tick_delay_us(uint32_t dly_us);

/*****************************************************************************/ 

void wait_ms(uint32_t delay);
uint16_t common_mem_cpy(uint8_t* src, uint8_t* dst, uint16_t len);
bool common_mem_cmp(uint8_t* a, uint8_t* b, uint16_t len);
void common_mem_xor(uint8_t* dst, uint8_t* msk, uint16_t len);

#endif
